import Vue from "vue";
import VueRouter from "vue-router";
import Layout from "@/views/layout";

Vue.use(VueRouter);

const routes = [
    {
        path: "/",
        name: "Layout",
        component: Layout,
        redirect: "/home",
        children: [
            {
                path: "home",
                name: "Home",
                component: () => import("@/views/home/index.vue"),
            },
        ],
    },
    {
        path: "/pms",
        name: "pms",
        component: Layout,
        redirect: "/pms/product", //重定向
        children: [
            {
                path: "product",
                name: "product",
                component: () => import("@/views/pms/product/index.vue"),
            },
            {
                path: "productadd",
                name: "productadd",
                component: () => import("@/views/pms/product/add.vue"),
            },
            {
                path: "productupdate/:id",
                name: "productupdate",
                component: () => import("@/views/pms/product/update.vue"),
            },
            {
                path: "productAttr",
                name: "productAttr",
                component: () => import("@/views/pms/productAttr/index.vue"),
            },
            {
                path: "productCate",
                name: "productCate",
                component: () => import("@/views/pms/productCate/index.vue"),
            },
            {
                path: "brand",
                name: "brand",
                component: () => import("@/views/pms/brand/index.vue"),
            },
        ],
    },
    {
        path: "/login",
        name: "Login",
        component: () => import("@/views/login"),
    },
    {
        path: "*",
        name: "page404",
        component: () => import("@/views/page404"),
    },
];

const router = new VueRouter({
    routes,
});

export default router;
